package com.heimachefu.module.user.entity;

import com.heimachefu.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * @author liuxingdong@heimachefu.com
 * @date 2019/7/19 11:27
 */
@Data
@Entity
@Table(name = "sys_user")
public class UserEntity implements UserDetails{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long userId;
    @Column(columnDefinition=" varchar(100) COMMENT '手机号'")
    private String mobile;
    @Column(columnDefinition=" varchar(100) COMMENT '用户名'")
    private String username;
    @Column(columnDefinition=" varchar(100) COMMENT '密码'")
    private String password;
    @Column(columnDefinition=" varchar(100) COMMENT '头像地址'")
    private String headPortraitUrl;
    //  账号类型 1：业务人员，2：开发人员，3：用户
    @Column(columnDefinition=" int(11) COMMENT '账号类型 1：业务人员，2：开发人员，3：用户'")
    private Integer accountType;
    @Column(columnDefinition=" int(2) COMMENT '能否使用，1：能，2：禁用'")
    private Integer ifUse;
    @Column(columnDefinition=" varchar(200) COMMENT 'QQ唯一标识'")
    private String qqOpenId;
    @Column(columnDefinition=" varchar(200) COMMENT '微信唯一标识'")
    private String webchatOpenId;
    @Column(columnDefinition=" varchar(200) COMMENT '备注'")
    private String  remark;
    private Timestamp createDate;
    private Timestamp updateDate;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
